package P1000;

import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-09-29 17:33
 */
public class P1003_铺地毯 {
    public static void main(String[] args) {
        int[][] input = new int[10001][4];
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        for(int i=0;i<num;++i){
           for(int j=0;j<4;++j){
               input[i][j] = scanner.nextInt();
           }
        }
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        scanner.close();
        invoke(input,x,y);
    }

    private static void invoke(int[][] input, int x, int y) {
        for(int i=input.length-1;i>=0;--i){
            if(x >= input[i][0] && x <= input[i][0]+input[i][2]
                    && y >= input[i][1]&& y <= input[i][1]+input[i][3]){
                System.out.println(i+1);
                return;
            }
        }
        System.out.println(-1);
    }

}
